<?php

namespace User\Model\Entity;

class User implements UserInterface {
	/**
	 * @var int
	 */
	protected $id;

	/**
	 * @var string
	 */
	protected $email;

	/**
	 * @var string
	 */
	protected $password;

	/**
	 * @var string
	 */
	protected $name;
	
	/**
	 * @var int
	 */
	protected $gender;
	
	/**
	 * @var date
	 */
	protected $dateBirth;
	
	/**
	 * @var int
	 */
	protected $cpf;
	
	/**
	 * @var string
	 */
	protected $job;
	
	/**
	 * @var int
	 */
	protected $phone1;
	
	/**
	 * @var int
	 */
	protected $phone2;
	
	/**
	 * @var text
	 */
	protected $biography;
	
	/**
	 * @var array
	 */
	protected $addresses;

	/**
	 * @var int
	 */
	protected $status;

	/**
	 * @var datetime
	 */
	protected $dateAdded;

	/**
	 * @author Tiago Peres da Silva <psilva.dev@gmail.com>
	 * @param array $data
	 */
	public function __construct($data = null) {
		if(is_array($data)) {
			$this->exchangeArray($data);
		}
	}

	/**
	 * The new array to exchange with the current object.
	 * @author Tiago Peres da Silva <psilva.dev@gmail.com>
	 * @param array $data
	 */
	public function exchangeArray(array $data) {
		$this->id			= (isset($data['user_id']))		? $data['user_id']		: null;
		$this->email		= (isset($data['email']))		? $data['email']		: null;
		$this->name			= (isset($data['name']))		? $data['name']			: null;
		$this->gender		= (isset($data['gender']))		? $data['gender']		: null;
		$this->dateBirth	= (isset($data['date_birth']))	? $data['date_birth']	: null;
		$this->cpf			= (isset($data['cpf']))			? $data['cpf']			: null;
		$this->job			= (isset($data['job']))			? $data['job']			: null;
		$this->phone1		= (isset($data['phone_1']))		? $data['phone_1']		: null;
		$this->phone2		= (isset($data['phone_2']))		? $data['phone_2']		: null;
		$this->biography	= (isset($data['biography']))	? $data['biography']	: null;
		$this->addresses	= (isset($data['addresses']))	? $data['addresses']	: null;
		$this->status		= (isset($data['status']))		? $data['status']		: null;
		$this->dateAdded	= (isset($data['date_added']))	? $data['date_added']	: null;
	}

	/**
	 * A copy of the array, or array of public properties if ArrayIterator refers to an object.
	 * @author Tiago Peres da Silva <psilva.dev@gmail.com>
	 * @return array
	 */
	public function getArrayCopy() {
		return get_object_vars($this);
	}

	/**
	 * @return int
	 */
	public function getId() {
		return $this->id;
	}

	/**
	 * @param int $id
	 * @return User
	 */
	public function setId($id) {
		$this->id = $id;
		return $this;
	}

	/**
	 * @return string
	 */
	public function getEmail() {
		return $this->email;
	}

	/**
	 * @param string $email
	 * @return User
	 */
	public function setEmail($email) {
		$this->email = $email;
		return $this;
	}

	/**
	 * @return string
	 */
	public function getPassword() {
		return $this->password;
	}

	/**
	 * @param string $password
	 * @return User
	 */
	public function setPassword($password) {
		$this->password = md5($password);
		return $this;
	}

	/**
	 * @return string
	 */
	public function getName() {
		return $this->name;
	}

	/**
	 * @param string $name
	 * @return User
	 */
	public function setName($name) {
		$this->name = $name;
		return $this;
	}

	/**
	 * @return int
	 */
	public function getGender() {
		return $this->gender;
	}

	/**
	 * @param int $gender
	 * @return User
	 */
	public function setGender($gender) {
		$this->gender = $gender;
		return $this;
	}
	
	/**
	 * @return date
	 */
	public function getDateBirth() {
		return $this->dateBirth;
	}

	/**
	 * @param date $dateBirth
	 * @return User
	 */
	public function setDateBirth($dateBirth) {
		$this->dateBirth = $dateBirth;
		return $this;
	}
	
	/**
	 * @return int
	 */
	public function getCpf() {
		return $this->cpf;
	}

	/**
	 * @param int $cpf
	 * @return User
	 */
	public function setCpf($cpf) {
		$this->cpf = $cpf;
		return $this;
	}
	
	/**
	 * @return string
	 */
	public function getJob() {
		return $this->job;
	}

	/**
	 * @param string $job
	 * @return User
	 */
	public function setJob($job) {
		$this->job = $job;
		return $this;
	}
	
	/**
	 * @return int
	 */
	public function getPhone1() {
		return $this->phone1;
	}

	/**
	 * @param int $phone1
	 * @return User
	 */
	public function setPhone1($phone1) {
		$this->phone1 = $phone1;
		return $this;
	}
	
	/**
	 * @return int
	 */
	public function getPhone2() {
		return $this->phone2;
	}

	/**
	 * @param int $phone2
	 * @return User
	 */
	public function setPhone2($phone2) {
		$this->phone2 = $phone2;
		return $this;
	}
	
	/**
	 * @return text
	 */
	public function getBiography() {
		return $this->biography;
	}

	/**
	 * @param text $biography
	 * @return User
	 */
	public function setBiography($biography) {
		$this->biography = $biography;
		return $this;
	}
	
	/**
	 * @return array
	 */
	public function getAddresses() {
		return $this->addresses;
	}

	/**
	 * @param array $addresses
	 * @return User
	 */
	public function setAddresses(array $addresses) {
		$this->addresses = $addresses;
		return $this;
	}

	/**
	 * @return int
	 */
	public function getStatus() {
		return $this->status;
	}

	/**
	 * @param int $status
	 * @return User
	 */
	public function setStatus($status) {
		$this->status = $status;
		return $this;
	}

	/**
	 * @return datetime
	 */
	public function getDateAdded() {
		return $this->dateAdded;
	}

	/**
	 * @param datetime $dateAdded
	 * @return User
	 */
	public function setDateAdded($dateAdded) {
		$this->dateAdded = $dateAdded;
		return $this;
	}
}